<template>
    <div style="position: relative;" v-for="(el) in arr">
        <div className="tee">疾病</div>
        <div className="content">
            <div className="con_1st">
                <span style="color: #00c792;">
                    <h1 style="display:inline-block"> {{ el.disease }} </h1>
                </span>
                <span class="sp4">
                    <el-icon><ArrowRightBold /></el-icon>
                </span>
            </div>

            <div className="con_2ed">
                <span>
                    就诊科室
                </span>
                <span>
                    {{ el.department.split("/")[0] }}
                </span>
            </div>

            <div className="con_3th">
                <span className="sp1">
                    词条作者
                </span>
                <img src="https://img1.dxycdn.com/2020/0429/433/3410515272170709616-22.png" alt="" />
                <span class="sp2" style="display:inline-block">
                    丁香医生医学团队
                </span>
            </div>

            <div className="con_3th">
                <span className="sp1">
                    审核专家
                </span>
                <img src="https://img1.dxycdn.com/2020/0429/433/3410515272170709616-22.png" alt="" />
                <span class="sp2" style="display:inline-block">
                    {{ el.experts }}
                </span>
                <span className="sp2">
                    {{ el.department.split("/")[0] }}
                </span>
                <span className="sp2">
                    {{ el.position }}
                </span>
            </div>

            <div className="con_4th">

                <li>{{ el.Introduction.split("/")[0] }}</li>
                <li>{{ el.Introduction.split("/")[1] }}</li>
                <li>{{ el.Introduction.split("/")[2] }}</li>

            </div>

            <div className="con_5th">
                <span className="sp3">
                    简介
                </span>
                <span className="sp3">
                    症状
                </span>
                <span className="sp3">
                    问诊
                </span>
            </div>
        </div>

        <div className="content">
            <div className="con_1st">
                <h2 style="display:inline-block"> 相关疾病 </h2>
            </div>

            <div className="con_5th">
                <span className="sp3" v-for="(el1 ) in (el.related as string).split('/')">
                    {{el1}}
                </span>
            </div>
        </div>
    </div>
</template>

<script setup lang="ts">
import { ref, onBeforeMount, onBeforeUpdate } from "vue"
import axios from "axios";
import { useRouter } from "vue-router";
import store from "@/store/S_zc"
let data = store().cache

let router = useRouter()

let arr: any = ref({})

onBeforeMount(() => {
    seaeched(data.str, data.ar[0])
})
onBeforeUpdate(() => {
    seaeched(data.str, data.ar[0])
})

async function seaeched(x: string, y?: string[]) {
    if (y) {
        if (y[0] == undefined) {
            // 显示没有
        } else {
            let re: any = await axios("/path/search", { params: { department: x, sec: true, table: y[0], field: y[1] } })
            arr.value = re.data.sql
            // console.log(typeof(arr.value),arr.value, "arrfff")
        }

    } else {
        let re: any = await axios("/path/search", { params: { department: x, table: data.ar[0][0], field: data.ar[0][1] } })
        arr.value = re.data.sql
    }
    if (arr.value[0] == undefined) {
        router.push('/Null')
    }

}



</script>

<style scoped  lang="scss">
* {
    margin: 0;
    padding: 0;
}

.tee {
    color: white;
    line-height: 44px;
    text-align: center;
    width: 44px;
    // height: 44px;
    padding: 6px;
    background-image: url(https://img1.dxycdn.com/2020/0817/120/0092694532778490343-22.png);
    background-size: 100%;
    position: absolute;
    top: -5px;
    right: 30px;
}

.content {
    background-color: white;
    padding: 28px 30px;
    margin-bottom: 20px;

    .con_1st {
        margin-bottom: 24px;
    }

    .con_2ed {
        margin-bottom: 16px;
    }

    .con_3th {
        display: flex;
        align-items: center;
        padding-top: 8px;

        .sp1 {
            padding: 4px;
            margin-right: 20px;
            flex-shrink: 0;
            font-size: 12px;
            line-height: 16px;
            color: #818993;
            border-radius: 4px;
            background-color: #f2f3f5;
        }

        .sp2 {
            flex-shrink: 10;
            margin-right: 4px;
            font-size: 14px;
            line-height: 18px;
            color: #99a0aa;
        }

        img {
            width: 18px;
            height: 18px;
            margin: 1px 8px 1px 1px;
        }
    }

    .con_4th {
        font-weight: 300;
        margin-top: 20px;
        font-size: 16px;
        line-height: 24px;
        color: #444c57;
    }

    .con_5th {
        margin-top: 12px;

        .sp3 {
            margin-right: 12px;
            padding: 4px 20px;
            text-overflow: ellipsis;
            border-radius: 4px;
            background-color: #f2f3f5;
            font-size: 13px;
            line-height: 18px;
            color: #444c57;
        }
    }
}

.sp4 {
    display:inline-block ;
    // width: 20px;
    padding:0 4px;
    font-weight: 700;
    background-color: #f2f3f5;
    // font-size: 16px;
    // line-height: 16px;
    color: #444c57;
}
</style>